package lucene.document
{
	public class Document
	{
		private var _fields:Array;
		
		public function Document()
		{
			this._fields = new Array;
		}
		
		public function getFields():Array
		{
			return this._fields;
		}
		
		public function getFieldVal(fieldName:String):String
		{
			if (this._fields[fieldName]) {
				return this._fields[fieldName].value;
			}
			else {
				throw new Error('Unknown ' + fieldName);
			}
		}
		
		public function getField(fieldName:String):Field
		{
			return this._fields[fieldName];
		}
		
		public function addField(field:Field):void
		{
			if (this._fields[field.name] != null) {
				throw new Error('Field ' + field.name + 'already exists in this document');
			}
			
			this._fields[field.name] = field;
		}

	}
}